{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# IEEE European Low Voltage Test Feeder: \n",
    "\n",
    "http://sites.ieee.org/pes-testfeeders/resources/\n",
    "\n",
    "The current IEEE test cases are focused on North American style systems; however it is common outside of North America to see low-voltage distribution systems, both radial and meshed. It is important to make sure that tools support both dominant styles of distribution system configuration. This test case seeks to fill a benchmark gap by presenting a number of common low-voltage configurations. This circuit also introduces quasi-static time series simulations.\n",
    "\n",
    "IEEE European LV network is a generic 0.416 kV network serviced by one 0.8 MVA MV/LV transformer and a 11kV external grid. The network supplies 906 LV buses and 55 single phase loads.\n",
    "\n",
    "# Snapshot of Time series data\n",
    "\n",
    "In the benchmark document, there are three snapshots taken from a time series data.\n",
    "\n",
    "- 12:01 AM : Off Peak(1 min) \n",
    "- 09:26 AM : On Peak (566 min)\n",
    "- 12:00 AM : Off Peak (1440 min)\n",
    "\n",
    "All the three networks have been saved into pandapower.networks \n",
    "We can select them using :\n",
    "\n",
    "- 'off_peak_1',\n",
    "- 'on_peak_566',\n",
    "- 'off_peak_1440'  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-20T06:24:47.667398Z",
     "start_time": "2025-10-20T06:24:43.269437Z"
    }
   },
   "outputs": [],
   "source": [
    "import pandapower.networks as nw\n",
    "\n",
    "net = nw.ieee_european_lv_asymmetric('on_peak_566')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Plotting the network\n",
    "\n",
    "- 11 KV External Grid ( cyan triangle)\n",
    "- 0.8 MVA 11/0.416 kV Transformer ( Intersecting Circles)\n",
    "- Loads \n",
    "    - Phase A: red triangles, \n",
    "    - Phase B: yellow box\n",
    "    - Phase C: blue circle\n",
    "\n",
    "**PS:**\n",
    "\n",
    "**Maximum unbalanced node 0.74% ( Black rectangle in the fig)**\n",
    "\n",
    "**Max Line Loading 33.10 % ( Black line in the fig)**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-20T06:24:48.117819Z",
     "start_time": "2025-10-20T06:24:47.674076Z"
    }
   },
   "outputs": [],
   "source": [
    "import pandapower.plotting as plot\n",
    "import numpy as np\n",
    "try:\n",
    "    import seaborn\n",
    "    colors = seaborn.color_palette()\n",
    "except:\n",
    "    colors = [\"b\", \"g\", \"r\", \"c\", \"y\"]\n",
    "%matplotlib inline\n",
    "\n",
    "sizes = plot.get_collection_sizes(net)\n",
    "\n",
    "# Plot all the buses\n",
    "bc = plot.create_bus_collection(net, net.bus.index, size=sizes['bus'], color=colors[0], zorder=10)\n",
    "\n",
    "#Plot Transformers\n",
    "tlc, tpc = plot.create_trafo_collection(net, net.trafo.index, color=\"g\", size=sizes['trafo'])\n",
    "\n",
    "# Plot all the lines\n",
    "lcd = plot.create_line_collection(net, net.line.index, color=\"grey\", linewidths=0.1, use_bus_geodata=True)\n",
    "\n",
    "# Plot the external grid\n",
    "sc = plot.create_ext_grid_collection(net, ext_grid_buses=net.ext_grid.bus.values, size=sizes['ext_grid'], color=\"c\", zorder=11)\n",
    "\n",
    "#Plot all the loads\n",
    "ldA = plot.create_bus_collection(net, net.asymmetric_load.bus.values[np.where(net.asymmetric_load.p_a_mw >0)], patch_type=\"poly3\", size=sizes['bus'], color=\"r\", zorder=11)\n",
    "ldB = plot.create_bus_collection(net, net.asymmetric_load.bus.values[np.where(net.asymmetric_load.p_b_mw >0)], patch_type=\"rect\", size=sizes['bus'], color=\"y\", zorder=11)\n",
    "ldC = plot.create_bus_collection(net, net.asymmetric_load.bus.values[np.where(net.asymmetric_load.p_c_mw >0)], patch_type=\"circle\", size=sizes['bus'], color=\"b\", zorder=11)\n",
    "\n",
    "# Plot the max. loaded line and max. unbalanced node\n",
    "max_load = plot.create_line_collection(net, np.array([net.res_line_3ph.loading_percent.idxmax()]), color=\"black\", linewidths=15, use_bus_geodata=True)\n",
    "max_unbal = plot.create_bus_collection(net, np.array([net.res_bus_3ph.unbalance_percent.idxmax()]), patch_type=\"rect\", size=sizes['bus'], color=\"black\", zorder=11)\n",
    "\n",
    "# Draw all the collected plots\n",
    "plot.draw_collections([lcd, bc, tlc, tpc, sc,ldA,ldB,ldC,max_load,max_unbal], figsize=(20,20))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Sample Result Values\n",
    "\n",
    "Max loaded line and most unbalanced load has been marked in black in the plot.\n",
    "\n",
    "The exact values are provided below:\n",
    "- Maximum unbalance %\n",
    "- Max Line Loading %"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-20T06:24:48.148662Z",
     "start_time": "2025-10-20T06:24:48.132124Z"
    }
   },
   "outputs": [],
   "source": [
    "net.res_bus_3ph.unbalance_percent.max()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2025-10-20T06:24:48.164009Z",
     "start_time": "2025-10-20T06:24:48.157013Z"
    }
   },
   "outputs": [],
   "source": [
    "net.res_line_3ph.loading_percent.max()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
